      SUBROUTINE  DENERG
      REAL*8  RAD,TMASS,GS,RHO0,GA
      REAL*8  D,H,RHO,ELAMB,EMU,GR,XI,PHI,ETA
      COMMON/MODEL /NLAY,ISO,LAME,NDIV,DMAX,ILAY,
     1              RAD,TMASS,GS,RHO0,GA,
     2              HI(500),RHOI(500),VPI(500),VSI(500),NAME(20),
     3              XII(500),PHII(500),ETAI(500),
     4              D(1000),H(1000),RHO(1000),ELAMB(1000),EMU(1000),
     5              GR(1000),XI(1000),PHI(1000),ETA(1000)
      REAL*8  RMAX,RC,HC,H1,H2,ALP,WN,WN2,C,C2,FRQ,FRQ2,T,U,ENGY,DELTA
      REAL*8  A,F,Y
      COMMON/VALUE /MODE,IERROR,I,ISTEP,J,K,L,N,NSOL,ISUM,KMAX,
     1              NMAX,IBOTM,ITOP,LY,LD,ACR,ELLIP,
     2              RMAX,RC,HC,H1,H2,ALP,WN,WN2,C,C2,FRQ,FRQ2,T,
     3              U,ENGY,DELTA,
     4              A(6,6),F(20),Y(6)
      REAL*8  YN,YB,SUM,Q
      COMMON/SOL/  YN(6,1000),YB(6,3,20),SUM(20),Q(3,21),
     1             WNB(100),TT(100),CC(100),UU(100),ENG(100),ELL(100),
     2             AC(100)
C
C ENERGY INTEGRALS IN THE INNERMOST HOMOGENEOUS SPHERE
C SINCE THE CONTRIBUTION FROM THE SPHERE R.LT.R(IBOTM) IS ASSUMED TO BE
C  NEGLIGIBLE, THIS PROGRAM COMPUTES ONLY THE GROUP VELOCITY AND THE
C  ACCURACY OF THE VARIATIONAL EQUATION
C MANTLE WAVES
C
      U=SUM(3)/(C*SUM(1))
      ENGY=FRQ2*SUM(1)
      ACR=(SUM(2)/ENGY)-1.0
      WNB(LY)=WN
      TT(LY)=T
      CC(LY)=C
      UU(LY)=U
      ENG(LY)=ENGY
      AC(LY)=ACR
      ELL(LY)=ELLIP
C
      RETURN
      END
